package com.zh.core;

import java.util.Arrays;

/**
 * Created by zhaohui on 2019/9/15
 * Description: 数组测试类
 */
public class ArrayTest {

    public static void main(String[] args) {
        //1.申明数组
        //int[] a;
        //2.创建数组
        //int[] a = new int[100];
        //3.创建匿名数组
        //new int[] {1, 2, 3, 4};
        //4.创建数组并赋初始值
        //int[] a = {1, 2, 3, 4};
        //5.获取数组长度
        //a.length;
        //6.数组排序
        //Arrays.sort(a);
        //7.数组转成String，方便输出
        //Arrays.toString(a);
        int[] a = new int[2];
        for (int i = 0; i < a.length; i++) {
            a[i] = i;
        }
        for (int i : a) {
            System.out.println(i);
        }
        for (String str : new String[] {"a", "b", "c"}) {
            System.out.println(str);
        }
        int[] b = {5, 2, 6, 9};
        System.out.println(Arrays.toString(b));
        Arrays.sort(b);
        System.out.println(Arrays.toString(b));
    }

}
